//
//  GoodsManagementViewCell.m
//  tuanGG
//
//  Created by 微他 on 15/9/21.
//  Copyright (c) 2015年 weita. All rights reserved.
//

#import "GoodsManagementViewCell.h"
#import "Header.h"
#import "AddGoodsController.h"
#import "GoodsManagementController.h"
@implementation GoodsManagementViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifierP{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifierP];
    if (self) {
        _nameIamge = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 80, 50)];
        [self addSubview:_nameIamge];
        
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(_nameIamge.frame.size.width+20,10,ScreenWidth-_nameIamge.frame.size.width-20 , 20)];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = [UIFont systemFontOfSize:18];
        [self addSubview:_nameLabel];
        
        _priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(_nameIamge.frame.size.width+20, _nameLabel.frame.size.height+20, 80, 20)];
        _priceLabel.font = [UIFont systemFontOfSize:15];
        _priceLabel.textAlignment = NSTextAlignmentLeft;
        _priceLabel.textColor = [UIColor redColor];
        [self addSubview:_priceLabel];
        
        _dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(_priceLabel.frame.size.width+_nameIamge.frame.size.width+30, _priceLabel.frame.origin.y, 120, 20)];
        _dateLabel.font = [UIFont systemFontOfSize:15];
        _dateLabel.textColor = [UIColor colorWithHexString:@"#969696"];
        [self addSubview:_dateLabel];
        
        _line = [[UIView alloc]initWithFrame:CGRectMake(0, _nameIamge.frame.size.height+20, ScreenWidth, 1)];
        _line.backgroundColor = [UIColor blackColor];
        _line.alpha = 0.1;
        [self addSubview:_line];
        _shelvesButton = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-60, _line.frame.origin.y+5, 50, 20)];
        _shelvesButton.layer.cornerRadius = 5;
        _shelvesButton.layer.borderWidth = 1;
        _shelvesButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _shelvesButton.layer.borderColor = [[UIColor colorWithHexString:@"#969696"]CGColor];
        [_shelvesButton setTitleColor:[UIColor colorWithHexString:@"#969696"] forState:UIControlStateNormal];
        
        _editorButton = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-140, _line.frame.origin.y+5, 50, 20)];
        _editorButton.layer.cornerRadius = 5;
        _editorButton.layer.borderWidth = 1;
        _editorButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _editorButton.layer.borderColor = [[UIColor colorWithHexString:@"#969696"]CGColor];
        [_editorButton setTitleColor:[UIColor colorWithHexString:@"#969696"] forState:UIControlStateNormal];
        [_editorButton setTitle:@"编辑" forState:UIControlStateNormal];
        [_editorButton addTarget:self action:@selector(editorButton:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_shelvesButton];
        [self addSubview:_editorButton];

    }
    return self;
}



#pragma mark - 事件实现
- (void)editorButton:(UIButton *)sender {
//    GoodsManagementController *goodsmanagement = [[GoodsManagementController alloc]init];
////    goodsmanagement.buttonBlock = ^(){
////        NSLog(@"编辑");
////    };
//    [goodsmanagement addButton];
    if (_jon) {
        _jon();
    }

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
